package org.subatu.orm.page;

import java.io.Serializable;
import java.util.List;

public class PageInfo implements Serializable {
    private static final long serialVersionUID = 1L;

    private List<?> list;
    // 当前页
    private int pageNum = 1;
    // 每页的数量
    private int pageSize = 10;
    // 总页数
    private int totalPage;
    // 总条数
    private long totalRow;

    // 排序列
    private String orderByColumn;
    // 是否asc : 默认倒序
    private String isAsc = "desc";
    // 是否第一页
    private boolean isFrist = false;
    // 是否最后一页
    private boolean isLast = false;
    // 是否有前一页
    private boolean isHavePrevious = false;
    // 是否有后一页
    private boolean isHaveNext = false;

    public PageInfo() {
    }

    public PageInfo(int pageNum, int pageSize) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
    }

    public PageInfo(List<?> result, int pageNum, int pageSize, int totalPage, long totalRow) {
        this.list = result;
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.totalPage = totalPage;
        this.totalRow = totalRow;
        // 设置
        this.isFrist = (pageNum == 1);
        this.isLast = (pageNum == totalPage);
        this.isHavePrevious = (pageNum > 1);
        this.isHaveNext = (pageNum < totalPage);
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public long getTotalRow() {
        return totalRow;
    }

    public void setTotalRow(long totalRow) {
        this.totalRow = totalRow;
    }

    public List<?> getList() {
        return list;
    }

    public void setList(List<?> list) {
        this.list = list;
    }

    public boolean isFrist() {
        return isFrist;
    }

    public void setFrist(boolean frist) {
        isFrist = frist;
    }

    public boolean isLast() {
        return isLast;
    }

    public void setLast(boolean last) {
        isLast = last;
    }

    public boolean isHavePrevious() {
        return isHavePrevious;
    }

    public void setHavePrevious(boolean havePrevious) {
        isHavePrevious = havePrevious;
    }

    public boolean isHaveNext() {
        return isHaveNext;
    }

    public void setHaveNext(boolean haveNext) {
        isHaveNext = haveNext;
    }

    public String getOrderByColumn() {
        return orderByColumn;
    }

    public void setOrderByColumn(String orderByColumn) {
        this.orderByColumn = orderByColumn;
    }

    public String getIsAsc() {
        return isAsc;
    }

    public void setIsAsc(String isAsc) {
        this.isAsc = isAsc;
    }


}
